package com.mobileares.midp.widgets.client.page;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Tom
 * Date: 2010-6-11
 * Time: 9:58:30
 * To change this template use File | Settings | File Templates.
 */
public class PageModel extends ItemModel{
    private String pageTitle;
    //页面的路径，eg:com.fish.client.page.MyPage
    private String pageId;
//    private AbstractPage page;
    private List<PageModel> children;

    private List<AbstractAccess> accesses;

    private List<WidgetFunction> widgetFunctions;

    private MenuModel menuModel;
    private Object userObject;

    public Object getUserObject() {
        return userObject;
    }

    public void setUserObject(Object userObject) {
        this.userObject = userObject;
    }

    public List<WidgetFunction> getWidgetFunctions() {
        return widgetFunctions;
    }

    public void setWidgetFunctions(List<WidgetFunction> widgetFunctions) {
        for (WidgetFunction function : widgetFunctions)
            WidgetFunctionManager.addWidgetFunction(function);
        this.widgetFunctions = widgetFunctions;
    }

    public void addAccess(AbstractAccess access) {
        if (accesses == null)
            accesses = new ArrayList();
        accesses.add(access);
    }

    public void removeAccess(AbstractAccess access) {
        if (accesses != null)
            accesses.remove(access);
    }

    public List<PageModel> getChildren() {
        return children;
    }

    public void setChildren(List<PageModel> children) {
        this.children = children;
    }

    public String getPageTitle() {
        return pageTitle;
    }

    public void setPageTitle(String pageTitle) {
        this.pageTitle = pageTitle;
    }

    public String getPageId() {
        return pageId;
    }

    public void setPageId(String pageId) {
        this.pageId = pageId;
    }

//    public AbstractPage getPage() {
//        return page;
//    }
//
//    public void setPage(AbstractPage page) {
//        this.page = page;
//    }

    public MenuModel getMenuModel() {
        return menuModel;
    }

    public void setMenuModel(MenuModel menuModel) {
        this.menuModel = menuModel;
    }

    public List<AbstractAccess> getAccesses() {
        return accesses;
    }

    public void setAccesses(List<AbstractAccess> accesses) {
        this.accesses = accesses;
    }

    public String getCode() {
        return pageId;
    }

    public String getText() {
        return pageTitle;
    }
}
